#include "mainwindow.h"
#include <QXmlStreamReader>
#include <QFile>
#include <QtDebug>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    QString fileName = "/home/work/uos-browser-114/chrome/app/resources/generated_resources_zh-TW.xtb";
    QFile file(fileName);
       if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
           qDebug() << "Failed to open the XML file.";
           return;
       }

    QXmlStreamReader xml(&file);

    while (!xml.atEnd() && !xml.hasError()) {
        QXmlStreamReader::TokenType token = xml.readNext();
        if (token == QXmlStreamReader::StartElement) {
            if (xml.name() == "translation") {
                // Read attributes
                QXmlStreamAttributes attributes = xml.attributes();
//                qWarning() << "Name:" << attributes.value("id").toString();
                m_ids.push_back(attributes.value("id").toString());
            }
        }
    }

    int len = m_ids.size();
    for(int i = 0 ; i < len ; i ++){
        int num = 0;
        auto item = m_ids.at(i);
        for(int j= i ; j < len ; j ++){
            auto tempItem2  =  m_ids.at(j);
               if(item == tempItem2)
               {
                    num++;
               }
        }
        if(num > 1){
             qWarning() << "Name:" << item;
        }
    }
}

MainWindow::~MainWindow()
{

}
